<?php


namespace app\common\model\mysql;


use think\Model;

class AdminUser extends Model
{
    /**
     * @param $username
     * @return array|false|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getAdminUserByUsername($username)
    {
        if (empty($username)) {
            return false;
        }

        return $this->where(['username' => $username])->find();
    }


    public function updateById($id, $data)
    {
        $id = intval($id);

        if (empty($id) || empty($data) || !is_array($data)) {
            return false;
        }

        return $this->where($id)->save($data);
    }
}